package org.linlinjava.litemall.admin.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.linlinjava.litemall.db.dao.LumiereSubscribeUserMapper;
import org.linlinjava.litemall.db.domain.LumiereSubscribeUser;
import org.linlinjava.litemall.db.domain.LumiereSubscribeUserExample;
import org.linlinjava.litemall.db.service.LumiereSubscribeUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * 管理卢米埃订阅用户服务
 *
 * @author yliyun
 * @date 2022/09/14
 */
@Service
public class AdminLumiereSubscribeUserService {
    /**
     * 卢米埃订阅用户服务
     */
    @Autowired
    private LumiereSubscribeUserService lumiereSubscribeUserService;

    /**
     * 查询用户列表
     *
     * @param userName 用户名
     * @param status   状态
     * @param page     页面
     * @param limit    限制
     * @param sort     排序
     * @param order    订单
     * @return {@link List}<{@link LumiereSubscribeUser}>
     */
    public IPage<LumiereSubscribeUser> queryUserList(String userName, Integer status
                                                    , Integer page, Integer limit, String sort, String order){
        LambdaQueryWrapper<LumiereSubscribeUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.like(userName != null,LumiereSubscribeUser::getUserName,userName);
        lambdaQueryWrapper.eq(status != null,LumiereSubscribeUser::getStatus,status);
        lambdaQueryWrapper.orderByDesc(LumiereSubscribeUser::getAddTime);
        lambdaQueryWrapper.eq(LumiereSubscribeUser::getDeleted,false);
        return lumiereSubscribeUserService.page(new Page<>(page,limit),lambdaQueryWrapper);
    }


}
